package cz.hanis.android.geography.models;

import java.util.ArrayList;
import java.util.List;


public class Country {
	
	private String id;
	//private String 	

	private String name;

	private String capital;
	private String continentId;
	private String continent;	

	private int population;	
	private int populationRank;
	private double populationDensity;
	private int area;
	private int areaRank;
	private List<String> languages;
	private String region;
	private Currency currency;
	private String tld;
	private String isoCode;
	private String government;
	
	private String wikiLink;
	
	private List<String> contiguousCountriesId;
	private List<Country> contiguousCountries;
	

	public Country() {			
		contiguousCountriesId = new ArrayList<String>();
		contiguousCountries = new ArrayList<Country>();
		languages = new ArrayList<String>();
	}	
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}	
	
	public String getContinent() {
		return continent;
	}

	public void setContinent(String continent) {
		this.continent = continent;
	}	
	
	public int getPopulation() {
		return population;
	}

	public void setPopulation(int population) {
		this.population = population;
	}

	public int getPopulationRank() {
		return populationRank;
	}

	public void setPopulationRank(int populationRank) {
		this.populationRank = populationRank;
	}

	public double getPopulationDensity() {
		return populationDensity;
	}

	public void setPopulationDensity(double populationDensity) {
		this.populationDensity = populationDensity;
	}

	public int getArea() {
		return area;
	}

	public void setArea(int area) {
		this.area = area;
	}

	public int getAreaRank() {
		return areaRank;
	}

	public void setAreaRank(int areaRank) {
		this.areaRank = areaRank;
	}

	public List<String> getLanguages() {
		return languages;
	}

	public void setLanguages(List<String> languages) {
		this.languages = languages;
	}
	
	public void addLanguage(String language) {
		languages.add(language);
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public Currency getCurrency() {
		return currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	public String getTld() {
		return tld;
	}

	public void setTld(String tld) {
		this.tld = tld;
	}

	public String getIsoCode() {
		return isoCode;
	}

	public void setIsoCode(String isoCode) {
		this.isoCode = isoCode;
	}

	public String getGovernment() {
		return government;
	}

	public void setGovernment(String government) {
		this.government = government;
	}

	public void setContiguousCountriesId(List<String> contiguousCountries) {
		this.contiguousCountriesId = contiguousCountries;
	}

	
	public void addContiguousCountryId(String country) {
		contiguousCountriesId.add(country);
	}
		
	public List<String> getContiguousCountriesId() {
		return contiguousCountriesId;
	}

	
	public List<Country> getContiguousCountries() {
		return contiguousCountries;
	}
	
	
	public void setContiguousCountries(List<Country> contiguousCountries) {
		this.contiguousCountries = contiguousCountries;
	}

	
	public void addContiguousCountry(Country country) {
		contiguousCountries.add(country);
	}	
	

	public String getCapital() {
		return capital;
	}

	public void setCapital(String capital) {
		this.capital = capital;
	}

	public String getContinentId() {
		return continentId;
	}

	public void setContinentId(String continentId) {
		this.continentId = continentId;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return getName();
	}
	
	public String writeContiguousCountries() {
		if(contiguousCountries.isEmpty()) {
			return "";
		}
		StringBuilder sb = new StringBuilder();
		for(Country country: contiguousCountries) {
			sb.append(country.getName()).append(", ");
		}
		return sb.substring(0, sb.length() - 2);		
	}

	
	public String writeLanguages() {
		if(languages.isEmpty()) {
			return "";
		}
		StringBuilder sb = new StringBuilder();
		for(String language: languages) {
			sb.append(language).append(", ");
		}
		return sb.substring(0, sb.length() - 2);		
	}
	
	
	public String getWikiLink() {
		return wikiLink;
	}

	public void setWikiLink(String wikiLink) {
		this.wikiLink = wikiLink;
	}

	@Override
	public boolean equals(Object o) {
		if(o instanceof Country) {
			Country country = (Country) o;
			return country.getId().equals(getId());
		}
		return false;
	}

	@Override
	public int hashCode() {
		return getId().hashCode();
	}
	
	
	
	
	
}
